Since we add one to the layout's reported width to account for the cursor,
authorOwen Taylor <otaylor@redhat.com>
Tue, 26 Aug 2003 00:06:18 +0000 (00:06 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 26 Aug 2003 00:06:18 +0000 (00:06 +0000)
Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktextview.c (gtk_text_view_update_layout_width):
        Since we add one to the layout's reported width to
        account for the cursor, we need to subtract one when
        setting the wrap width for the layout. (Fixes infinite
        loop (#120325, Federico Crozat)

        * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
        Be a bit more careful about rounding when converting
        wrapped width from Pango units to pixels.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextlayout.c
gtk/gtktextview.c

index 78ea6e6746104ce8c500cf99d2bfd81932990942..6f25b59035462591e860c6183fa12ca833729cd8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_update_layout_width): 
+       Since we add one to the layout's reported width to
+       account for the cursor, we need to subtract one when
+       setting the wrap width for the layout. (Fixes infinite
+       loop (#120325, Federico Crozat)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): 
+       Be a bit more careful about rounding when converting
+       wrapped width from Pango units to pixels.
+
 2003-08-26  Matthias Clasen  <maclas@gmx.de>
 
         Rename GtkMenuMerge to GtkUIManager. 
index 78ea6e6746104ce8c500cf99d2bfd81932990942..6f25b59035462591e860c6183fa12ca833729cd8 100644 (file)
@@ -1,3 +1,15 @@
+Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_update_layout_width): 
+       Since we add one to the layout's reported width to
+       account for the cursor, we need to subtract one when
+       setting the wrap width for the layout. (Fixes infinite
+       loop (#120325, Federico Crozat)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): 
+       Be a bit more careful about rounding when converting
+       wrapped width from Pango units to pixels.
+
 2003-08-26  Matthias Clasen  <maclas@gmx.de>
 
         Rename GtkMenuMerge to GtkUIManager. 
index 78ea6e6746104ce8c500cf99d2bfd81932990942..6f25b59035462591e860c6183fa12ca833729cd8 100644 (file)
@@ -1,3 +1,15 @@
+Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_update_layout_width): 
+       Since we add one to the layout's reported width to
+       account for the cursor, we need to subtract one when
+       setting the wrap width for the layout. (Fixes infinite
+       loop (#120325, Federico Crozat)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): 
+       Be a bit more careful about rounding when converting
+       wrapped width from Pango units to pixels.
+
 2003-08-26  Matthias Clasen  <maclas@gmx.de>
 
         Rename GtkMenuMerge to GtkUIManager. 
index 78ea6e6746104ce8c500cf99d2bfd81932990942..6f25b59035462591e860c6183fa12ca833729cd8 100644 (file)
@@ -1,3 +1,15 @@
+Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_update_layout_width): 
+       Since we add one to the layout's reported width to
+       account for the cursor, we need to subtract one when
+       setting the wrap width for the layout. (Fixes infinite
+       loop (#120325, Federico Crozat)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): 
+       Be a bit more careful about rounding when converting
+       wrapped width from Pango units to pixels.
+
 2003-08-26  Matthias Clasen  <maclas@gmx.de>
 
         Rename GtkMenuMerge to GtkUIManager. 
index 78ea6e6746104ce8c500cf99d2bfd81932990942..6f25b59035462591e860c6183fa12ca833729cd8 100644 (file)
@@ -1,3 +1,15 @@
+Mon Aug 25 19:55:55 2003  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_update_layout_width): 
+       Since we add one to the layout's reported width to
+       account for the cursor, we need to subtract one when
+       setting the wrap width for the layout. (Fixes infinite
+       loop (#120325, Federico Crozat)
+
+       * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): 
+       Be a bit more careful about rounding when converting
+       wrapped width from Pango units to pixels.
+
 2003-08-26  Matthias Clasen  <maclas@gmx.de>
 
         Rename GtkMenuMerge to GtkUIManager. 
index 52e77813718728afe138c8bfd844e3aa78d8ee9a..3fed7624c47c7943f53b085f628233f8d43c4cb1 100644 (file)
@@ -122,6 +122,8 @@ enum {
   LAST_ARG
 };
 
+#define PIXEL_BOUND(d) (((d) + PANGO_SCALE - 1) / PANGO_SCALE)
+
 static void gtk_text_layout_init       (GtkTextLayout      *text_layout);
 static void gtk_text_layout_class_init (GtkTextLayoutClass *klass);
 static void gtk_text_layout_finalize   (GObject            *object);
@@ -1972,7 +1974,7 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout,
 
   pango_layout_get_extents (display->layout, NULL, &extents);
 
-  display->width = PANGO_PIXELS (extents.width) + display->left_margin + display->right_margin;
+  display->width = PIXEL_BOUND (extents.width) + display->left_margin + display->right_margin;
   display->height += PANGO_PIXELS (extents.height);
   
   /* Free this if we aren't in a loop */
index 0b748f81f041a89be8dfd924808614bb7a3a229c..c79c136a659986cb8f397647054304732cb0d4b7 100644 (file)
@@ -94,6 +94,8 @@
 #define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window)
 #define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window)
 
+#define SPACE_FOR_CURSOR 1
+
 struct _GtkTextPendingScroll
 {
   GtkTextMark   *mark;
@@ -1702,7 +1704,7 @@ gtk_text_view_update_adjustments (GtkTextView *text_view)
     gtk_text_layout_get_size (text_view->layout, &width, &height);
 
   /* Make room for the cursor after the last character in the widest line */
-  width++;
+  width += SPACE_FOR_CURSOR;
 
   if (text_view->width != width || text_view->height != height)
     {
@@ -1742,7 +1744,7 @@ gtk_text_view_update_layout_width (GtkTextView *text_view)
   gtk_text_view_ensure_layout (text_view);
 
   gtk_text_layout_set_screen_width (text_view->layout,
-                                    SCREEN_WIDTH (text_view));
+                                    MAX (1, SCREEN_WIDTH (text_view) - SPACE_FOR_CURSOR));
 }
 
 static void